package com.atguigu.Servlet;

import com.atguigu.pojo.Book;
import com.atguigu.service.BookService;
import com.atguigu.service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 类说明：
 *
 * @author ChenCheng
 * @ClassName BookServlet
 * @create 2023-02-10 17:17
 * @Version 1.0
 */
public class BookServlet extends BaseServlet{

    private BookService bookService = new BookServiceImpl();

    protected void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1.通过bookService查询全部图书
        List<Book> books = bookService.queryBooks();
        // 2.将全部图书保存到request域中
        request.setAttribute("books",books);
        // 3.请求转发到/pages/manager/book_manager.jsp
        request.getRequestDispatcher("/pages/manager/book_manager.jsp").forward(request,response);
    }
}
